'''配置文件'''

import logging
import os
from logging.handlers import RotatingFileHandler
log_dir = os.getcwd()+'/log'
if not os.path.exists(log_dir):
    os.makedirs(log_dir)

def mylog():
    logger = logging.getLogger(__name__)
    logger.setLevel(level = logging.DEBUG)
    # handler = logging.FileHandler("log.txt",encoding='utf-8')
    handler = RotatingFileHandler(os.path.join(log_dir,"log.txt"),maxBytes = 5*1024*1024,backupCount = 5,encoding='utf-8')
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)
    logger.addHandler(handler)
    logger.addHandler(console)
    return logger
logger = mylog()

plate_pos = ["11","12","13","21",'22']
pot_pos = ["11","12","21","22","31","32"]
pot_pos_screen={"11":"32","12":"31","21":"22","22":"21","31":"12","32":"11"}
import argparse
def parse_args():
    parser = argparse.ArgumentParser(description='MMDetection webcam demo')
    parser.add_argument('--config', help='test config file path',default="model\\configs\\rtmdet\\rtmdet_tiny_8xb32-300e_coco_dacai.py")
    parser.add_argument('--checkpoint', help='checkpoint file',default="model\\rtmdet_tiny\\epoch_180.pth")
    # parser.add_argument('--onnx', help='onnx file',default="mmdeploy_models\\mmdet\\onnx")
    parser.add_argument(
        '--device', type=str, default='cuda:0', help='CPU/CUDA device option')#cuda:0
    parser.add_argument(
        '--camera_id', type=int, default=0, help='camera device id')
    parser.add_argument(
        '--score-thr', type=float, default=0.65, help='bbox score threshold')
    parser.add_argument('--classes',type=dict,default=["plate","plate_chopsticks","plate_blank","plate_circle","pot"])
    parser.add_argument('--robot_ip',type=str,default= "192.168.3.4")
    parser.add_argument('--max_vision_edge',default=[320,80,980,600])#[280,0,1570,400]

    parser.add_argument('--get_order_url',default="http://shp.test.xixiang000.com/api/Index/getNoodleShopwaitingorder")
    parser.add_argument('--update_order_url',default="http://shp.test.xixiang000.com/api/Index/orderupdate")
    parser.add_argument('--shop_serial',default="jxsdc") #
    parser.add_argument('--shop_id',default="55",type=str,help="门店编号") 
    parser.add_argument('--menuid_name',default={"CLK124":"方腿毛豆","MDJ777":"素肠毛豆肉片","MDJ265":"花生(测试)","MDJ651":"瓜子(测试)","MDJ001":"玉米(测试)","MDJ867":"青豆玉米虾仁"})
    parser.add_argument('--stander_plate_dir',default=os.getcwd()+"/standerd_img/plate")
    parser.add_argument('--stander_pot_dir',default=os.getcwd()+"/standerd_img/pot")
    parser.add_argument('--pot_robot_map',default={pot_pos[0]:4,pot_pos[1]:1,pot_pos[2]:5,pot_pos[3]:2,pot_pos[4]:6,pot_pos[5]:3})
    parser.add_argument('--mqtt_plate',default={"plate_exist":0,"plate_empty":{plate_pos[0]:1,plate_pos[1]:1,plate_pos[2]:1,plate_pos[4]:1}})#,plate_pos[3]:1}
    parser.add_argument('--mqtt_pot',default={"pot_menu":{"11":{},"12":{},"21":{},"22":{},"31":{},"32":{}}})
    parser.add_argument('--mqtt_host',default="47.102.110.192",help='mqtt主机')
    parser.add_argument('--mqtt_client_id',default="dacaitai",help='客户端id')
    parser.add_argument("--mqtt_topic_palte_pub",default='/xixiang/visioncook/55/plate/post',help='发布主题')
    parser.add_argument("--mqtt_topic_pot_pub",default='/xixiang/visioncook/55/pot/post',help='发布主题')
    parser.add_argument("--mqtt_username",default="")
    parser.add_argument("--mqtt_password",default="")
    args = parser.parse_args()
    return args
